POV-Ray : Newsgroups : povray.advanced-users : Max-value with function int() : Max-value with function int() Server Time
29 Jul 2024 00:31:01 EDT (-0400)
  Max-value with function int()  
From: Jaap Frank
Date: 13 May 2003 19:02:20
Message: <3ec1797c$1@news.povray.org>
Hello,

when I was testing how I can translate a float like

1.23456789e-28

into a 6 bytes notation for a ppm file I noticed that
the float function int() has a maximum value.
Try this:

*************************************
#declare Num1 = pow(2,30);
#declare Num2 = pow(2,31);
#declare Num3 = pow(2,32);
#declare Int1 = int(Num1);
#declare Int2 = int(Num2);
#declare Int3 = int(Num3);
#debug concat("\nNum1 = ",str(Num1,0,-1),
       " | Num2 = ",str(Num2,0,-1),
       " | Num3 = ",str(Num1,0,-1))
#debug concat("\nInt1 = ",str(Int1,0,-1),
       " | Int2 = ",str(Int2,0,-1),
       " | Int3 = ",str(Int3,0,-1),"\n")
*************************************
The result for me was:

Persistence of Vision(tm) Ray Tracer Version 3.5 win32 (.icl)
....
Num1 = 1073741824.000000 | Num2 = 2147483648.000000 | Num3 = 1073741824.000000
Int1 = 1073741824.000000 | Int2 = -2147483648.000000 | Int3 = -2147483648.000000

There is no warning about a max value in the manual.
Maybe it is wise to do this.

Jaap Frank


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.